package com.robinloveshadow.goodnight.sounds;

import android.content.Context;
import android.media.AudioManager;
import android.util.Log;

public class SoundsManager {
	private final String TAG = "SoundsManager";
	private final boolean D = true;
	
	private static SoundsManager sSoundsManager;
	
	private AudioManager mAudioManager;
	private Context mContext;
	private int mSoundsMaxValue;
	private int mSoundsCurValue;
	private int mRingerMode;
	
	public SoundsManager(Context context){
		mContext = context;
		mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
	}
	
	public static SoundsManager getInstance(Context context){
		if(sSoundsManager == null){
			sSoundsManager = new SoundsManager(context);
		}
		return sSoundsManager;
	}
	
	public int getMaxSound() {
		
		mSoundsMaxValue = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_SYSTEM);
		return mSoundsMaxValue;
//		max = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
//		current = mAudioManager.getStreamVolume(AudioManager.STREAM_RING);
//		Log.d(TAG, "max : " + max + " current : " + current);
	}
	
	public int getCurrentSound(){
		mSoundsCurValue = mAudioManager.getStreamVolume(AudioManager.STREAM_SYSTEM);
		return mSoundsCurValue;
	}
	
	public void setSoundsValue(int value){
		mAudioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, value ,AudioManager.FLAG_ALLOW_RINGER_MODES);
	}
	
	public void setRingerMode(int modeType){
		mAudioManager.setRingerMode(modeType);
	}
}
